package org.example.curriculum_design_6_16.mapper;

import org.apache.ibatis.annotations.*;
import org.example.curriculum_design_6_16.entity.pojo.IpScoringRule;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;

import java.util.List;

/**
* @author 郑凯
* @description 针对表【ip_scoring_rule(知识产权评分规则表)】的数据库操作Mapper
* @createDate 2025-06-23 09:02:07
* @Entity org.example.curriculum_design_6_16.entity.pojo.IpScoringRule
*/
@Mapper
public interface IpScoringRuleMapper extends BaseMapper<IpScoringRule> {
    @Insert("INSERT INTO ip_scoring_rule(ip_type, status, score, description, effective_date, is_active, " +
            "max_times_per_year, team_leader_bonus, team_member_bonus) " +
            "VALUES(#{ipType}, #{status}, #{score}, #{description}, #{effectiveDate}, #{isActive}, " +
            "#{maxTimesPerYear}, #{teamLeaderBonus}, #{teamMemberBonus})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int insertIpScoringRule(IpScoringRule ipScoringRule);

    @Update("UPDATE ip_scoring_rule SET " +
            "ip_type=#{ipType}, status=#{status}, score=#{score}, description=#{description}, " +
            "effective_date=#{effectiveDate}, is_active=#{isActive}, max_times_per_year=#{maxTimesPerYear}, " +
            "team_leader_bonus=#{teamLeaderBonus}, team_member_bonus=#{teamMemberBonus} " +
            "WHERE id=#{id}")
    int updateIpScoringRule(IpScoringRule ipScoringRule);

    @Delete("DELETE FROM ip_scoring_rule WHERE id=#{id}")
    int deleteIpScoringRuleById(Integer id);

    @Select("SELECT * FROM ip_scoring_rule WHERE id=#{id}")
    IpScoringRule getIpScoringRuleById(Integer id);

    @Select("SELECT * FROM ip_scoring_rule")
    List<IpScoringRule> getAllIpScoringRules();

    @Select("SELECT * FROM ip_scoring_rule WHERE ip_type=#{ipType} AND status=#{status}")
    IpScoringRule getIpScoringRuleByTypeAndStatus(@Param("ipType") String ipType, @Param("status") String status);

    @Select("SELECT DISTINCT ip_type FROM ip_scoring_rule WHERE ip_type IS NOT NULL AND ip_type != ''")
    List<String> getAllDistinctIpTypes();
}




